package com.runa.monitor.platinterface.task;

import com.runa.monitor.platinterface.backwork.function.TaskFunction;
import com.runa.persistence.task.RequestPendingTask;
import com.runa.rccprotocol.dto.ConcentratorRequestData;
import lombok.Data;
import org.jetbrains.annotations.NotNull;

/**
 * 2024/11/7 17:57
 * zhangYB
 */
@Data
public class RequestTask implements Comparable<RequestTask> {

    private ConcentratorRequestData requestData;
    private TaskFunction taskFunction;
    private RequestPendingTask task;

    private RequestTask next;

    public RequestTask(ConcentratorRequestData requestData, TaskFunction taskFunction) {
        this(requestData, taskFunction, new RequestPendingTask());
    }

    public RequestTask(ConcentratorRequestData requestData, TaskFunction taskFunction, RequestPendingTask task) {
        this.requestData = requestData;
        this.taskFunction = taskFunction;
        this.task = task;
    }

    @Override
    public int compareTo(@NotNull RequestTask task) {
        return task.taskFunction.getPriority() - this.taskFunction.getPriority();
    }

    private boolean used = false;

    public void setUsed(boolean used) {
        this.used = used;
    }

    public boolean notUse() {
        return !used;
    }
}
